#include "moduleb.h"
#include <stdio.h>
#include "../ModuleA/modulea.h"


void addCourse() {
    if (courseCount >= MAX_COURSES) {
        printf("Course database is full.\n");
        return;
    }

    Course course;
    printf("Enter course ID: ");
    scanf("%d", &course.id);
    printf("Enter course name: ");
    scanf("%s", course.name);
    printf("Enter course credits: ");
    scanf("%d", &course.credits);
    printf("Enter course hours: ");
    scanf("%d", &course.hours);
    course.selectedCount = 0;
    printf("Enter course maximum capacity: ");
    scanf("%d", &course.maxCapacity);

    courses[courseCount++] = course;

    printf("Course added successfully.\n");
}

void deleteCourse() {
    int id;
    printf("Enter course ID: ");
    scanf("%d", &id);

    int i;
    for (i = 0; i < courseCount; i++) {
        if (courses[i].id == id) {
            int j;
            for (j = i; j < courseCount - 1; j++) {
                courses[j] = courses[j + 1];
            }
            courseCount--;
            printf("Course deleted successfully.\n");
            return;
        }
    }

    printf("Course not found.\n");
}

void viewCourseDetails() {
    int id;
    printf("Enter course ID: ");
    scanf("%d", &id);

    int i;
    for (i = 0; i < courseCount; i++) {
        if (courses[i].id == id) {
            printf("Course ID: %d\n", courses[i].id);
            printf("Course name: %s\n", courses[i].name);
            printf("Credits: %d\n", courses[i].credits);
            printf("Hours: %d\n", courses[i].hours);
            printf("Selected count: %d\n", courses[i].selectedCount);
            printf("Maximum capacity: %d\n", courses[i].maxCapacity);
            return;
        }
    }

    printf("Course not found.\n");
}

void modifyCourse() {
    int id;
    printf("Enter course ID: ");
    scanf("%d", &id);

    int i;
    for (i = 0; i < courseCount; i++) {
        if (courses[i].id == id) {
            printf("Enter new course credits: ");
            scanf("%d", &courses[i].credits);
            printf("Enter new course hours: ");
            scanf("%d", &courses[i].hours);
            printf("Course modified successfully.\n");
            return;
        }
    }

    printf("Course not found.\n");
}
void updateSelectedCourse(Course* courses) {
    for (int i = 0; i < MAX_COURSES; i++) {
        courses[i].selectedCount = coursePeople[courses[i].id];
    }
}